package com.ymttest.business.service.YMTTrading;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

import com.ymatou.iapi.optrade.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.optrade.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.optrade.parameter.vo.CouponVo;
import com.ymatou.iapi.optrade.parameter.vo.OrderGroupVo;
import com.ymatou.iapi.optrade.parameter.vo.OrderItemVo;
import com.ymatou.iapi.optrade.parameter.vo.OrderVo;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.EnvSetup;

public class TradingPlaceAnliOrderCallService {
	
	private static Long sellerId = Long.valueOf(EnvSetup.getData("autotest_seller1"));
	private static String sellerName = String.valueOf(EnvSetup.getData("autotest_sellerName1"));

	public static boolean isAnliMember(Integer orderType) {
		
		if (orderType == null)
			return false;
		else if (orderType == 2 || orderType == 3)
			return true;
		else 
			return false;
	}
	
	/**
	 * 创建一个安利会订单
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(BigDecimal rebateAmount, boolean isUserCoupon) throws Exception {

		return placeAnlihuiOrder(rebateAmount, isUserCoupon, 3);
	}
	
	/**
	 * 创建一个安利会订单
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(BigDecimal rebateAmount, boolean isUserCoupon, int orderType) throws Exception {

		return placeAnlihuiOrder(rebateAmount, isUserCoupon, 5678L, orderType);
	}
	
	/**
	 * 创建一个安利会订单
	 * @param rebateAmount
	 * @param isUserCoupon
	 * @param orderType
	 * @param rebateRatios
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(BigDecimal rebateAmount,
			boolean isUserCoupon, int orderType, List<BigDecimal> rebateRatios) throws Exception {

		return placeAnlihuiOrder(20238699L, rebateAmount, isUserCoupon, 2002L,
				orderType, rebateRatios, null);
	}
	
	/**
	 * 创建一个安利会订单
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param memeberId
	 *            邀请人id          
	 * @param orderType
	 *            订单类型
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(BigDecimal rebateAmount,
			boolean isUserCoupon, Long memeberId, int orderType) throws Exception {

		return placeAnlihuiOrder(20238699L, rebateAmount, isUserCoupon,
				memeberId, orderType, Arrays.asList(new BigDecimal("0.1982"),
						new BigDecimal("0.3123")), null);
	}

	/**
	 * 创建一个安利会订单
	 * @param userId
	 * @param rebateAmount
	 * @param isUserCoupon
	 * @param memeberId
	 * @param orderType
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(long userId, BigDecimal rebateAmount,
			boolean isUserCoupon, Long memeberId, int orderType) throws Exception {

		return placeAnlihuiOrder(userId, rebateAmount, isUserCoupon, memeberId,
				orderType, Arrays.asList(new BigDecimal("0.1982"),
						new BigDecimal("0.3123")), null);
	}
	
	/**
	 * 创建一个安利会订单
	 * @param userId
	 * @param rebateAmount
	 * @param isUserCoupon
	 * @param memeberId
	 * @param orderType
	 * @param linkPayAnliOrderId
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeAnlihuiOrder(long userId, BigDecimal rebateAmount,
			boolean isUserCoupon, Long memeberId, int orderType, Long linkPayAnliOrderId) throws Exception {

		return placeAnlihuiOrder(userId, rebateAmount, isUserCoupon, memeberId,
				orderType, Arrays.asList(new BigDecimal("0.1982"),
						new BigDecimal("0.3123")), linkPayAnliOrderId);
	}
	
	/**
	 * 
	 * @param userId
	 * @param rebateAmount
	 * @param isUserCoupon
	 * @param memeberId
	 * @param orderType
	 * @param rebateRatios
	 * @param linkPayAnliOrderId
	 * @return
	 * @throws Exception
	 */
	public static TradingServiceResp placeAnlihuiOrder(long userId, BigDecimal rebateAmount,
			boolean isUserCoupon, Long memeberId, int orderType, List<BigDecimal> rebateRatios, Long linkPayAnliOrderId) throws Exception {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo));
		orderGroupVo.setOrders(Arrays.asList(orderVo));
		
		//如果买家的rebateAmount不足，则充值
		if (rebateAmount.compareTo(BigDecimal.ZERO) > 0) {
			
			String accountid1 = AccountCallServiceV2.getAccountId((int)userId, 5);
			
			if (AccountCallServiceV2.getAccountBalance((int)userId, 5).compareTo(rebateAmount) == -1)
				AccountCallServiceV2.resetAccount(accountid1, rebateAmount, new BigDecimal(0));
			
			placeOrderReq.setRebatePaidAmount(rebateAmount);
		}
		
		if (null != linkPayAnliOrderId)
			orderVo.setLinkPayAnliOrderId(linkPayAnliOrderId);
		
		if (orderType == 2 || orderType == 3)
			orderVo.setLogisticsType(LogisticsTypeEnum.AutoDelivery);
		
		orderVo.setOrderType(orderType);

		orderItemVo.setSellerRebateRatio(rebateRatios.get(0));
		orderItemVo.setRebateRatio(rebateRatios.get(1));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");

		if (isUserCoupon) {

			// 平台券
			placeOrderReq.setYmatouCoupon(TradingAllPromotion.createYMTCouponVo(
					userId, BigDecimal.TEN, BigDecimal.ONE));
			// 商家券
			CouponVo sellerCoupon1 = TradingAllPromotion.createSellerCouponVo(
					userId, sellerId, new BigDecimal(30), BigDecimal.TEN);

			orderGroupVo.setSellerCoupon(sellerCoupon1);
		}
		
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));
		placeOrderReq.setUserId(userId);
		placeOrderReq.setShareUserId(memeberId);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建一个最大返点金额的安利会订单
	 * @param userId
	 *            买家id
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param memeberId
	 *            邀请人id          
	 * @param orderType
	 *            订单类型
	 * @return
	 * @throws Exception 
	 */
	public static TradingServiceResp placeMaxRebateAmountAnlihuiOrder(BigDecimal rebateAmount,
			long memeberId, int orderType, List<BigDecimal> rebateRatios) throws Exception {

		int userId = new OrderCallService().createNewUser();
		
		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
	
		BigDecimal rebatePaidAmount = BigDecimal.TEN;

		placeOrderReq.setShareUserId(memeberId);
		
		if (rebateAmount.compareTo(BigDecimal.ZERO) > 0)
			placeOrderReq.setRebatePaidAmount(rebatePaidAmount);

		orderVo.setOrderType(orderType);

		orderItemVo.setProductPrice(new BigDecimal("5000"));
		orderItemVo.setSellerRebateRatio(rebateRatios.get(0));
		orderItemVo.setRebateRatio(rebateRatios.get(1));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo));
		orderGroupVo.setOrders(Arrays.asList(orderVo));
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));

		placeOrderReq.setUserId(userId);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建一个安利会订单,包含多个商品
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @return
	 */
	public static TradingServiceResp placeMultiProAnlihuiOrder(
			BigDecimal rebateAmount, boolean isUserCoupon, int orderType) {

		return placeMultiProAnlihuiOrder(rebateAmount, isUserCoupon, 5678L,
				orderType);
	}
	
	/**
	 * 创建一个安利会订单,包含多个商品
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @param shareUserId
	 *            推介人id
	 * @return
	 */
	public static TradingServiceResp placeMultiProAnlihuiOrder(
			BigDecimal rebateAmount, boolean isUserCoupon, long shareUserId, int orderType) {

		return placeMultiProAnlihuiOrder(rebateAmount, isUserCoupon, shareUserId, orderType, true);
	}
	
	/**
	 * 创建一个安利会订单,包含多个商品
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @param shareUserId
	 *            推介人id
	 * @return
	 */
	public static TradingServiceResp placeMultiProAnlihuiOrder(
			BigDecimal rebateAmount, boolean isUserCoupon, long shareUserId, int orderType, boolean allAnlihui) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		
		long userId = placeOrderReq.getUserId();

		BigDecimal rebatePaidAmount = BigDecimal.TEN;

		orderVo.setOrderType(orderType);
		
		orderItemVo.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		// 创建第二个普通商品
		TradingProductVo pro = TradingProductVo.createPro(
				sellerId,
				sellerName, 100);
		
		//创建第二个orderItem
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				pro.getProductId(), pro.getCatalogId());
		
		if (allAnlihui) {
			
			orderItemVo2.setSellerRebateRatio(new BigDecimal("0.1123"));
			orderItemVo2.setRebateRatio(new BigDecimal("0.1982"));
			orderItemVo2.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		}
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo, orderItemVo2));

		if (isUserCoupon) {

			// 平台券
			placeOrderReq.setYmatouCoupon(TradingAllPromotion.createYMTCouponVo(
					userId, BigDecimal.TEN, BigDecimal.ONE));
			// 商家券
			CouponVo sellerCoupon1 = TradingAllPromotion.createSellerCouponVo(
					userId, Long.valueOf(EnvSetup.getData("autotest_seller1")),
					new BigDecimal(30), BigDecimal.TEN);

			orderGroupVo.setSellerCoupon(sellerCoupon1);
		}
		
		orderGroupVo.setOrders(Arrays.asList(orderVo));
		
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));
		placeOrderReq.setShareUserId(shareUserId);
		placeOrderReq.setRebatePaidAmount(rebatePaidAmount);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建一个安利会订单,包含多个商品
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param orderType
	 *            订单类型
	 * @param shareUserId
	 *            推介人id
	 * @return
	 */
	public static TradingServiceResp placeMultiProAnlihuiOrder(
			long userId, Long shareUserId, int orderType, boolean allAnlihui) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		
		orderVo.setOrderType(orderType);
		
		orderItemVo.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		// 创建第二个普通商品
		TradingProductVo pro = TradingProductVo.createPro(sellerId, sellerName,
				100);
		
		//创建第二个orderItem
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				pro.getProductId(), pro.getCatalogId());
		
		if (allAnlihui) {
			
			orderItemVo2.setSellerRebateRatio(new BigDecimal("0.1123"));
			orderItemVo2.setRebateRatio(new BigDecimal("0.1982"));
			orderItemVo2.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		}
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo, orderItemVo2));

		orderGroupVo.setOrders(Arrays.asList(orderVo));
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));

		placeOrderReq.setUserId(userId);
		placeOrderReq.setShareUserId(shareUserId);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建多个安利会订单
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @return
	 */
	public static TradingServiceResp placeMultiAnlihuiOrder(BigDecimal rebateAmount, boolean isUserCoupon) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		long userId = placeOrderReq.getUserId();	
		BigDecimal rebatePaidAmount = BigDecimal.TEN;
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		orderItemVo.setProductNum(5);
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo));
		
		orderVo.setOrderType(3);
		orderVo.setLogisticsType(LogisticsTypeEnum.AutoDelivery);	
		
		// 创建第二个普通商品
		TradingProductVo pro2 = TradingProductVo.createPro(sellerId,
				sellerName, 100);

		// 创建第二个orderItem
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				pro2.getProductId(), pro2.getCatalogId());

		orderItemVo2.setSellerRebateRatio(new BigDecimal("0.1123"));
		orderItemVo2.setRebateRatio(new BigDecimal("0.1982"));
		orderItemVo2.setAnliPromotionRuleId("autotestAnliPromotionRuleId");

		OrderVo orderVo2 = TradingCallService.createOrderVo();
		orderVo2.getOrderItems().add(orderItemVo2);

		if (isUserCoupon) {

			// 平台券
			placeOrderReq.setYmatouCoupon(TradingAllPromotion.createYMTCouponVo(
					userId, BigDecimal.TEN, BigDecimal.ONE));
			// 商家券
			CouponVo sellerCoupon1 = TradingAllPromotion.createSellerCouponVo(
					userId, sellerId, new BigDecimal(30), BigDecimal.TEN);

			orderGroupVo.setSellerCoupon(sellerCoupon1);
		}
		
		orderGroupVo.setOrders(Arrays.asList(orderVo, orderVo2));
		
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));
		placeOrderReq.setShareUserId(5678L);
		placeOrderReq.setRebatePaidAmount(rebatePaidAmount);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建多个安利会订单
	 * 
	 * @param rebateAmount
	 *            返点金额
	 * @param isUserCoupon
	 *            是否使用优惠券
	 * @param isAllRebateOrder
	 *            是否都是安利会订单
	 * @return
	 */
	public static TradingServiceResp placeMultiProAnlihuiMultiOrder(
			long userId, long shareUserId, boolean isAllRebateOrder) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();

		placeOrderReq.setUserId(userId);
		placeOrderReq.setShareUserId(shareUserId);
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product1 = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo1 = TradingCallService.createOrderItemVo(
				product1.getProductId(), product1.getCatalogId());
		
		orderItemVo1.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo1.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo1.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		// 创建第二个普通商品
		TradingProductVo product2 = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				product2.getProductId(), product2.getCatalogId());
		
		orderItemVo2.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo2.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo2.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		orderVo.setOrderType(0);
		orderVo.setOrderItems(Arrays.asList(orderItemVo1, orderItemVo2));
		
		OrderVo orderVo2 = TradingCallService.createOrderVo();
		
		// 创建第三个普通商品
		TradingProductVo product3 = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo3 = TradingCallService.createOrderItemVo(
				product3.getProductId(), product3.getCatalogId());
		
		if (isAllRebateOrder) {
					
			orderItemVo3.setSellerRebateRatio(new BigDecimal("0.1982"));
			orderItemVo3.setRebateRatio(new BigDecimal("0.3123"));
			orderItemVo3.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
			
			orderVo2.setOrderType(0);
		}
		
		orderGroupVo.setOrders(Arrays.asList(orderVo, orderVo2));
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建安利会会员和安利会普通商品订单组
	 * @return
	 */
	public static TradingServiceResp placeAnlihuiMemberAndAnlihuiNormalOrderGroup(
			long userId, long shareUserId, int orderType) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		
		orderItemVo.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo));
		orderVo.setOrderType(0);
		
		orderGroupVo.setOrders(Arrays.asList(orderVo));
		
		// 第二个订单组
		OrderGroupVo orderGroupVo2 = TradingCallService.createOrderGroupVo(3383L, "wesper");
		TradingProductVo productVo2 = TradingProductVo.createPro(3383L, "wesper", 10);
		OrderVo orderVo2 = TradingCallService.createOrderVo();
		
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				productVo2.getProductId(), productVo2.getCatalogId());
		
		orderVo2.setOrderType(orderType);
		orderVo2.setOrderItems(Arrays.asList(orderItemVo2));

		orderGroupVo2.setOrders(Arrays.asList(orderVo2));
		
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo, orderGroupVo2));
		placeOrderReq.setUserId(userId);
		placeOrderReq.setShareUserId(shareUserId);

		return TradingCallService.callPlaceOrderService(placeOrderReq);
	}
	
	/**
	 * 创建安利会会员和安利会普通商品订单
	 * @return
	 */
	public static TradingServiceResp placeAnlihuiMemberAndAnlihuiNormalOrder(
			long userId, long shareUserId, int orderType) {

		PlaceOrderReq placeOrderReq = TradingCallService
				.buildStandPlaceOrderReq();
		
		OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(sellerId, sellerName);
		OrderVo orderVo = TradingCallService.createOrderVo();
		
		// 创建一个普通商品
		TradingProductVo product = TradingProductVo.createPro(sellerId,
				sellerName, 100);
		
		OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
				product.getProductId(), product.getCatalogId());
		
		orderItemVo.setSellerRebateRatio(new BigDecimal("0.1982"));
		orderItemVo.setRebateRatio(new BigDecimal("0.3123"));
		orderItemVo.setAnliPromotionRuleId("autotestAnliPromotionRuleId");
		
		orderVo.setOrderItems(Arrays.asList(orderItemVo));	
		orderVo.setOrderType(0);	
		
		TradingProductVo productVo = TradingProductVo.createPro(sellerId, sellerName, 10);
		OrderItemVo orderItemVo2 = TradingCallService.createOrderItemVo(
				productVo.getProductId(), productVo.getCatalogId());
		
		OrderVo orderVo2 = TradingCallService.createOrderVo();
		
		orderVo2.setOrderItems(Arrays.asList(orderItemVo2));	
		orderVo2.setLogisticsType(LogisticsTypeEnum.AutoDelivery);
		orderVo2.setOrderType(orderType);
			
		orderGroupVo.setOrders(Arrays.asList(orderVo, orderVo2));
		
		placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));	
		placeOrderReq.setUserId(userId);
		placeOrderReq.setShareUserId(shareUserId);

		return TradingCallService.callPlaceOrderService(placeOrderReq);

	}
}
